package com.zjj.lbw.microservice.gateway.gatewayservice.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

/**
 * @author zhanglei.zjj
 * @description 使用RequestRateLimiter过滤器工厂 进行Gateway限流
 * @date 2023/8/2 1:39
 */
//@Configuration
public class RateLimiterConfig {
    @Bean
    KeyResolver keyResolver() {
        //url限流
        return exchange -> Mono.just(exchange.getRequest().getURI().getPath());
        //参数限流
        //return exchange -> Mono.just(exchange.getRequest().getQueryParams().getFirst("user"));
    }
}
